<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" value="点击打开新的页面" id="btn_new">
<input type="button" value="点击关闭页面" id="btn_old">
<script>
    let btnNew = document.getElementById("btn_new");
    let btnOld = document.getElementById("btn_old")
    let newWindow;
    btnNew.onclick = function(){
         newWindow = window.open("https://www.baidu.con");

    }
    btnOld.onclick = function(){
        newWindow.close();
    }
</script>
</body>
</html>